home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / linux / src / atalnx_3.lzh / atari-linux-0.01pl3 / tools / atari / a.out.h next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  7.6 KB  |  277 lines

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file README.legal in the main directory of this archive
  4.  * for more details.
  5.  */
  6.  
  7. #ifndef __A_OUT_GNU_H__
  8. #define __A_OUT_GNU_H__
  9.  
  10. #define __GNU_EXEC_MACROS__
  11.  
  12. #ifndef __STRUCT_EXEC_OVERRIDE__
  13.  
  14. struct exec
  15. {
  16.   unsigned long a_info;        /* Use macros N_MAGIC, etc for access */
  17.   unsigned a_text;        /* length of text, in bytes */
  18.   unsigned a_data;        /* length of data, in bytes */
  19.   unsigned a_bss;        /* length of uninitialized data area for file, in bytes */
  20.   unsigned a_syms;        /* length of symbol table data in file, in bytes */
  21.   unsigned a_entry;        /* start address */
  22.   unsigned a_trsize;        /* length of relocation info for text, in bytes */
  23.   unsigned a_drsize;        /* length of relocation info for data, in bytes */
  24. };
  25.  
  26. #endif /* __STRUCT_EXEC_OVERRIDE__ */
  27.  
  28. /* these go in the N_MACHTYPE field */
  29. enum machine_type {
  30. #if defined (M_OLDSUN2)
  31.   M__OLDSUN2 = M_OLDSUN2,
  32. #else
  33.   M_OLDSUN2 = 0,
  34. #endif
  35. #if defined (M_68010)
  36.   M__68010 = M_68010,
  37. #else
  38.   M_68010 = 1,
  39. #endif
  40. #if defined (M_68020)
  41.   M__68020 = M_68020,
  42. #else
  43.   M_68020 = 2,
  44. #endif
  45. #if defined (M_SPARC)
  46.   M__SPARC = M_SPARC,
  47. #else
  48.   M_SPARC = 3,
  49. #endif
  50.   /* skip a bunch so we don't run into any of sun's numbers */
  51.   M_386 = 100,
  52. };
  53.  
  54. #if !defined (N_MAGIC)
  55. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  56. #endif
  57. #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  58. #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  59. #define N_SET_INFO(exec, magic, type, flags) \
  60.     ((exec).a_info = ((magic) & 0xffff) \
  61.      | (((int)(type) & 0xff) << 16) \
  62.      | (((flags) & 0xff) << 24))
  63. #define N_SET_MAGIC(exec, magic) \
  64.     ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
  65.  
  66. #define N_SET_MACHTYPE(exec, machtype) \
  67.     ((exec).a_info = \
  68.      ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  69.  
  70. #define N_SET_FLAGS(exec, flags) \
  71.     ((exec).a_info = \
  72.      ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  73.  
  74. /* Code indicating object file or impure executable.  */
  75. #define OMAGIC 0407
  76. /* Code indicating pure executable.  */
  77. #define NMAGIC 0410
  78. /* Code indicating demand-paged executable.  */
  79. #define ZMAGIC 0413
  80. /* This indicates a demand-paged executable with the header in the text. 
  81.    The first page is unmapped to help trap NULL pointer references */
  82. #define QMAGIC 0314
  83.  
  84. /* Code indicating core file.  */
  85. #define CMAGIC 0421
  86.  
  87. #if !defined (N_BADMAG)
  88. #define N_BADMAG(x)      (N_MAGIC(x) != OMAGIC        \
  89.             && N_MAGIC(x) != NMAGIC        \
  90.               && N_MAGIC(x) != ZMAGIC \
  91.                 && N_MAGIC(x) != QMAGIC)
  92. #endif
  93.  
  94. #define _N_HDROFF(x) (1024 - sizeof (struct exec))
  95.  
  96. #if !defined (N_TXTOFF)
  97. #define N_TXTOFF(x) \
  98.  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
  99.   (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
  100. #endif
  101.  
  102. #if !defined (N_DATOFF)
  103. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  104. #endif
  105.  
  106. #if !defined (N_TRELOFF)
  107. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  108. #endif
  109.  
  110. #if !defined (N_DRELOFF)
  111. #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
  112. #endif
  113.  
  114. #if !defined (N_SYMOFF)
  115. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
  116. #endif
  117.  
  118. #if !defined (N_STROFF)
  119. #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
  120. #endif
  121.  
  122. /* Address of text segment in memory after it is loaded.  */
  123. #if !defined (N_TXTADDR)
  124. #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
  125. #endif
  126.  
  127. /* Address of data segment in memory after it is loaded.
  128.    Note that it is up to you to define SEGMENT_SIZE
  129.    on machines not listed here.  */
  130. #if defined(vax) || defined(hp300) || defined(pyr)
  131. #define SEGMENT_SIZE page_size
  132. #endif
  133. #ifdef    sony
  134. #define    SEGMENT_SIZE    0x2000
  135. #endif    /* Sony.  */
  136. #ifdef is68k
  137. #define SEGMENT_SIZE 0x20000
  138. #endif
  139. #if defined(m68k) && defined(PORTAR)
  140. #define PAGE_SIZE 0x400
  141. #define SEGMENT_SIZE PAGE_SIZE
  142. #endif
  143.  
  144. #ifdef linux
  145. #include <linux/page.h>
  146. #define SEGMENT_SIZE    1024
  147. #endif
  148.  
  149. #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
  150.  
  151. #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
  152.  
  153. #ifndef N_DATADDR
  154. #define N_DATADDR(x) \
  155.     (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
  156.      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  157. #endif
  158.  
  159. /* Address of bss segment in memory after it is loaded.  */
  160. #if !defined (N_BSSADDR)
  161. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  162. #endif
  163.  
  164. #if !defined (N_NLIST_DECLARED)
  165. struct nlist {
  166.   union {
  167.     char *n_name;
  168.     struct nlist *n_next;
  169.     long n_strx;
  170.   } n_un;
  171.   unsigned char n_type;
  172.   char n_other;
  173.   short n_desc;
  174.   unsigned long n_value;
  175. };
  176. #endif /* no N_NLIST_DECLARED.  */
  177.  
  178. #if !defined (N_UNDF)
  179. #define N_UNDF 0
  180. #endif
  181. #if !defined (N_ABS)
  182. #define N_ABS 2
  183. #endif
  184. #if !defined (N_TEXT)
  185. #define N_TEXT 4
  186. #endif
  187. #if !defined (N_DATA)
  188. #define N_DATA 6
  189. #endif
  190. #if !defined (N_BSS)
  191. #define N_BSS 8
  192. #endif
  193. #if !defined (N_FN)
  194. #define N_FN 15
  195. #endif
  196.  
  197. #if !defined (N_EXT)
  198. #define N_EXT 1
  199. #endif
  200. #if !defined (N_TYPE)
  201. #define N_TYPE 036
  202. #endif
  203. #if !defined (N_STAB)
  204. #define N_STAB 0340
  205. #endif
  206.  
  207. /* The following type indicates the definition of a symbol as being
  208.    an indirect reference to another symbol.  The other symbol
  209.    appears as an undefined reference, immediately following this symbol.
  210.  
  211.    Indirection is asymmetrical.  The other symbol's value will be used
  212.    to satisfy requests for the indirect symbol, but not vice versa.
  213.    If the other symbol does not have a definition, libraries will
  214.    be searched to find a definition.  */
  215. #define N_INDR 0xa
  216.  
  217. /* The following symbols refer to set elements.
  218.    All the N_SET[ATDB] symbols with the same name form one set.
  219.    Space is allocated for the set in the text section, and each set
  220.    element's value is stored into one word of the space.
  221.    The first word of the space is the length of the set (number of elements).
  222.  
  223.    The address of the set is made into an N_SETV symbol
  224.    whose name is the same as the name of the set.
  225.    This symbol acts like a N_DATA global symbol
  226.    in that it can satisfy undefined external references.  */
  227.  
  228. /* These appear as input to LD, in a .o file.  */
  229. #define    N_SETA    0x14        /* Absolute set element symbol */
  230. #define    N_SETT    0x16        /* Text set element symbol */
  231. #define    N_SETD    0x18        /* Data set element symbol */
  232. #define    N_SETB    0x1A        /* Bss set element symbol */
  233.  
  234. /* This is output from LD.  */
  235. #define N_SETV    0x1C        /* Pointer to set vector in data area.  */
  236.  
  237. #if !defined (N_RELOCATION_INFO_DECLARED)
  238. /* This structure describes a single relocation to be performed.
  239.    The text-relocation section of the file is a vector of these structures,
  240.    all of which apply to the text section.
  241.    Likewise, the data-relocation section applies to the data section.  */
  242.  
  243. struct relocation_info
  244. {
  245.   /* Address (within segment) to be relocated.  */
  246.   int r_address;
  247.   /* The meaning of r_symbolnum depends on r_extern.  */
  248.   unsigned int r_symbolnum:24;
  249.   /* Nonzero means value is a pc-relative offset
  250.      and it should be relocated for changes in its own address
  251.      as well as for changes in the symbol or section specified.  */
  252.   unsigned int r_pcrel:1;
  253.   /* Length (as exponent of 2) of the field to be relocated.
  254.      Thus, a value of 2 indicates 1<<2 bytes.  */
  255.   unsigned int r_length:2;
  256.   /* 1 => relocate with value of symbol.
  257.           r_symbolnum is the index of the symbol
  258.       in file's the symbol table.
  259.      0 => relocate with the address of a segment.
  260.           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  261.       (the N_EXT bit may be set also, but signifies nothing).  */
  262.   unsigned int r_extern:1;
  263.   /* Four bits that aren't used, but when writing an object file
  264.      it is desirable to clear them.  */
  265. #ifdef NS32K
  266.   unsigned r_bsr:1;
  267.   unsigned r_disp:1;
  268.   unsigned r_pad:2;
  269. #else
  270.   unsigned int r_pad:4;
  271. #endif
  272. };
  273. #endif /* no N_RELOCATION_INFO_DECLARED.  */
  274.  
  275.  
  276. #endif /* __A_OUT_GNU_H__ */
  277.